package com.example.glidelearningproject.extension;

import androidx.annotation.NonNull;

import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.annotation.GlideExtension;
import com.bumptech.glide.annotation.GlideOption;
import com.bumptech.glide.annotation.GlideType;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.BaseRequestOptions;
import com.bumptech.glide.request.RequestOptions;

@GlideExtension
public class MyAppExtension {
    private static final RequestOptions DECODE_TYPE_GIF = RequestOptions.decodeTypeOf(GifDrawable.class).lock();

    private MyAppExtension() {
    }

    @NonNull
    @GlideOption
    public static BaseRequestOptions<?> miniThumb(BaseRequestOptions<?> options,int size){
        return options.fitCenter().override(size);
    }

    @NonNull
    @GlideType(GifDrawable.class)
    public static RequestBuilder<GifDrawable> asMyGif(RequestBuilder<GifDrawable> requestBuilder){
        return requestBuilder.transition(new DrawableTransitionOptions()).apply(DECODE_TYPE_GIF);
    }
}
